﻿/*
* ========================================================================
* 类说明：
*   
* 
* 作者：HGS   时间：2024/12/3 8:36:51
* 
* 修改者：         时间：           
* 修改说明：
* ========================================================================
*/

using EasyTest.Shared.EnumType;
using EasyTest.Shared.TestAttribute;
using EasyTest.Shared.外部访问;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ZLGCANoptimize.方法;

namespace ZLGCANoptimize
{
    public class Part4新
    {
        [ExposedMethodAttribute("")]
        public bool 读取NADIPADDRESS1(int 通道, out string 响应值, out int 字节长度, out string 信息)
        {
#if ELO20240927
            信息 = "";
            响应值 = "";
            字节长度 = 响应值.Length;
            try
            {
                List<CanCmdModel> cmdList = new List<CanCmdModel>();
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "03 22 B0 06 00 00 00 00" });
                CanReadRequestModel requestModel = new CanReadRequestModel();
                requestModel.Channel = (ushort)通道;
                requestModel.IsClearCache = false;
                requestModel.IsDecode = false;
                requestModel.DecodeLevel = "62";
                requestModel.CmdList = cmdList;
                requestModel.SendCmdTimeSpan = 50;
                requestModel.ReceiveCmdTimeSpan = 1500;
                requestModel.MaxSendCount = 1;
                requestModel.AutoParse = true;
                requestModel.IsVerifyDid = true;
                requestModel.RequestMode = CanRequestMode.发送并接收;

                var 发送响应 = 数据.发送指令(requestModel);
                if (发送响应.Success == false)
                {
                    字节长度 = 发送响应.ResultList.Count();
                    信息 = 发送响应.ErrorMessage;
                    响应值 = string.Join(",", 发送响应.ResultList ?? new List<string>());
                    return false;
                }

                信息 = string.Join(",", 发送响应.ResultList);
                响应值 = 发送响应.ResultHex;
                字节长度 = 响应值.Length;

                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                响应值 = "";
               // LogHelper.Error($"[Part4.读取NADIPADDRESS1]异常，{ex.Message}，{ex.StackTrace}");
                eLog.AddLog($"[Part4.读取NADIPADDRESS1]异常，{ex.Message}，{ex.StackTrace}", eMsgType.Error);
            }
            return false;
#else
            信息 = "";
            响应值 = "";
            字节长度 = 响应值.Length;
            try
            {
                List<CanCmdModel> cmdList = new List<CanCmdModel>();
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "03 22 B0 06 00 00 00 00" });
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "30 08 14 00 00 00 00 00" });
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "30 08 14 00 00 00 00 00" });
                CanReadRequestModel requestModel = new CanReadRequestModel();
                requestModel.Channel = (ushort)通道;
                requestModel.IsClearCache = false;
                requestModel.IsDecode = false;
                requestModel.DecodeLevel = "62";
                requestModel.CmdList = cmdList;
                requestModel.SendCmdTimeSpan = 50;
                requestModel.ReceiveCmdTimeSpan = 1500;
                requestModel.MaxSendCount = 1;
                requestModel.AutoParse = true;
                requestModel.IsVerifyDid = true;
                requestModel.RequestMode = CanRequestMode.发送并接收;

                var 发送响应 = 数据.发送指令(requestModel);
                if (发送响应.Success == false)
                {
                    字节长度 = 发送响应.ResultList.Count();
                    信息 = 发送响应.ErrorMessage;
                    响应值 = string.Join(",", 发送响应.ResultList ?? new List<string>());
                    return false;
                }

                信息 = string.Join(",", 发送响应.ResultList);
                响应值 = 发送响应.ResultHex;
                字节长度 = 响应值.Length;

                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                响应值 = "";
                LogHelper.Error($"[Part4.读取NADIPADDRESS1]异常，{ex.Message}，{ex.StackTrace}");
            }
            return false;
#endif
        }
        [ExposedMethodAttribute("")]
        public bool 读取NADIPADDRESS1B006(int 通道, out string 响应值, out int 字节长度, out string 信息)
        {
#if ELO20240927
            信息 = "";
            响应值 = "";
            字节长度 = 响应值.Length;
            try
            {
                List<CanCmdModel> cmdList = new List<CanCmdModel>();
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "03 22 B0 06 00 00 00 00" });
                CanReadRequestModel requestModel = new CanReadRequestModel();
                requestModel.Channel = (ushort)通道;
                requestModel.IsClearCache = false;
                requestModel.IsDecode = false;
                requestModel.DecodeLevel = "62";
                requestModel.CmdList = cmdList;
                requestModel.SendCmdTimeSpan = 50;
                requestModel.ReceiveCmdTimeSpan = 1500;
                requestModel.MaxSendCount = 1;
                requestModel.AutoParse = true;
                requestModel.IsVerifyDid = true;
                requestModel.RequestMode = CanRequestMode.发送并接收;

                var 发送响应 = 数据.发送指令(requestModel);
                if (发送响应.Success == false)
                {
                    字节长度 = 发送响应.ResultList.Count();
                    信息 = 发送响应.ErrorMessage;
                    响应值 = string.Join(",", 发送响应.ResultList ?? new List<string>());
                    return false;
                }

                信息 = string.Join(",", 发送响应.ResultList);
                响应值 = 发送响应.ResultHex;
                字节长度 = 响应值.Length;

                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                响应值 = "";
                //LogHelper.Error($"[Part4.读取NADIPADDRESS1B006]异常，{ex.Message}，{ex.StackTrace}");
                eLog.AddLog($"[Part4.读取NADIPADDRESS1B006]异常，{ex.Message}，{ex.StackTrace}", eMsgType.Error);
            }
            return false;
#else
            信息 = "";
            响应值 = "";
            字节长度 = 响应值.Length;
            try
            {
                List<CanCmdModel> cmdList = new List<CanCmdModel>();
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "03 22 B0 06 00 00 00 00" });
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "30 08 14 00 00 00 00 00" });
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "30 08 14 00 00 00 00 00" });
                CanReadRequestModel requestModel = new CanReadRequestModel();
                requestModel.Channel = (ushort)通道;
                requestModel.IsClearCache = false;
                requestModel.IsDecode = false;
                requestModel.DecodeLevel = "62";
                requestModel.CmdList = cmdList;
                requestModel.SendCmdTimeSpan = 50;
                requestModel.ReceiveCmdTimeSpan = 1500;
                requestModel.MaxSendCount = 1;
                requestModel.AutoParse = true;
                requestModel.IsVerifyDid = true;
                requestModel.RequestMode = CanRequestMode.发送并接收;

                var 发送响应 = 数据.发送指令(requestModel);
                if (发送响应.Success == false)
                {
                    字节长度 = 发送响应.ResultList.Count();
                    信息 = 发送响应.ErrorMessage;
                    响应值 = string.Join(",", 发送响应.ResultList ?? new List<string>());
                    return false;
                }

                信息 = string.Join(",", 发送响应.ResultList);
                响应值 = 发送响应.ResultHex;
                字节长度 = 响应值.Length;

                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                响应值 = "";
                LogHelper.Error($"[Part4.读取NADIPADDRESS1B006]异常，{ex.Message}，{ex.StackTrace}");
            }
            return false;
#endif
        }
        [ExposedMethodAttribute("")]
        public bool 读取NADIPADDRESS2B007(int 通道, out string 响应值, out int 字节长度, out string 信息)
        {
#if ELO20240927
            信息 = "";
            响应值 = "";
            字节长度 = 响应值.Length;
            try
            {
                List<CanCmdModel> cmdList = new List<CanCmdModel>();
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "03 22 B0 07 00 00 00 00" });
                CanReadRequestModel requestModel = new CanReadRequestModel();
                requestModel.Channel = (ushort)通道;
                requestModel.IsClearCache = false;
                requestModel.IsDecode = false;
                requestModel.DecodeLevel = "62";
                requestModel.CmdList = cmdList;
                requestModel.SendCmdTimeSpan = 50;
                requestModel.ReceiveCmdTimeSpan = 1500;
                requestModel.MaxSendCount = 1;
                requestModel.AutoParse = true;
                requestModel.IsVerifyDid = true;
                requestModel.RequestMode = CanRequestMode.发送并接收;

                var 发送响应 = 数据.发送指令(requestModel);
                if (发送响应.Success == false)
                {
                    字节长度 = 发送响应.ResultList.Count();
                    信息 = 发送响应.ErrorMessage;
                    响应值 = string.Join(",", 发送响应.ResultList ?? new List<string>());
                    return false;
                }

                信息 = string.Join(",", 发送响应.ResultList);
                响应值 = 发送响应.ResultHex;
                字节长度 = 响应值.Length;

                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                响应值 = "";
                //LogHelper.Error($"[Part4.读取NADIPADDRESS2B007]异常，{ex.Message}，{ex.StackTrace}");
                eLog.AddLog($"[Part4.读取NADIPADDRESS2B007]异常，{ex.Message}，{ex.StackTrace}", eMsgType.Error);
            }
            return false;
#else
            信息 = "";
            响应值 = "";
            字节长度 = 响应值.Length;
            try
            {
                List<CanCmdModel> cmdList = new List<CanCmdModel>();
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "03 22 B0 07 00 00 00 00" });
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "30 08 14 00 00 00 00 00" });
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "30 08 14 00 00 00 00 00" });
                CanReadRequestModel requestModel = new CanReadRequestModel();
                requestModel.Channel = (ushort)通道;
                requestModel.IsClearCache = false;
                requestModel.IsDecode = false;
                requestModel.DecodeLevel = "62";
                requestModel.CmdList = cmdList;
                requestModel.SendCmdTimeSpan = 50;
                requestModel.ReceiveCmdTimeSpan = 1500;
                requestModel.MaxSendCount = 1;
                requestModel.AutoParse = true;
                requestModel.IsVerifyDid = true;
                requestModel.RequestMode = CanRequestMode.发送并接收;

                var 发送响应 = 数据.发送指令(requestModel);
                if (发送响应.Success == false)
                {
                    字节长度 = 发送响应.ResultList.Count();
                    信息 = 发送响应.ErrorMessage;
                    响应值 = string.Join(",", 发送响应.ResultList ?? new List<string>());
                    return false;
                }

                信息 = string.Join(",", 发送响应.ResultList);
                响应值 = 发送响应.ResultHex;
                字节长度 = 响应值.Length;

                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                响应值 = ""
                LogHelper.Error($"[Part4.读取NADIPADDRESS2B007]异常，{ex.Message}，{ex.StackTrace}");
            }
            return false;
#endif
        }

        [ExposedMethodAttribute("")]
        public bool 读GNSS基本信息(int 通道, out string 响应值, out string 信息, out string 经纬度)
        {
#if ELO20240927
            信息 = "";
            响应值 = "";
            经纬度 = "";
            try
            {
                List<CanCmdModel> cmdList = new List<CanCmdModel>();
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "03 22 B0 04 00 00 00 00" });
                CanReadRequestModel requestModel = new CanReadRequestModel();
                requestModel.Channel = (ushort)通道;
                requestModel.IsClearCache = false;
                requestModel.IsDecode = false;
                requestModel.DecodeLevel = "62";
                requestModel.CmdList = cmdList;
                requestModel.SendCmdTimeSpan = 50;
                requestModel.ReceiveCmdTimeSpan = 1500;
                requestModel.MaxSendCount = 1;
                requestModel.AutoParse = true;
                requestModel.IsVerifyDid = true;
                requestModel.RequestMode = CanRequestMode.发送并接收;

                var 发送响应 = 数据.发送指令(requestModel);
                if (发送响应.Success == false)
                {
                    信息 = 发送响应.ErrorMessage;
                    响应值 = string.Join(",", 发送响应.ResultList ?? new List<string>());
                    return false;
                }

                信息 = string.Join(",", 发送响应.ResultList);
                响应值 = 发送响应.ResultHex;
                经纬度 = $"纬度：{发送响应.ResultHex.Substring(0, 8)}，经度：{发送响应.ResultHex.Substring(8, 8)}";

                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                响应值 = "";
               // LogHelper.Error($"[Part4.读GNSS基本信息]异常，{ex.Message}，{ex.StackTrace}");
                eLog.AddLog($"[Part4.读GNSS基本信息]异常，{ex.Message}，{ex.StackTrace}", eMsgType.Error);
            }
            return false;
#else
            信息 = "";
            响应值 = "";
            经纬度 = "";
            try
            {
                List<CanCmdModel> cmdList = new List<CanCmdModel>();
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "03 22 B0 04 00 00 00 00" });
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "30 08 14 00 00 00 00 00" });
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "30 08 14 00 00 00 00 00" });
                CanReadRequestModel requestModel = new CanReadRequestModel();
                requestModel.Channel = (ushort)通道;
                requestModel.IsClearCache = false;
                requestModel.IsDecode = false;
                requestModel.DecodeLevel = "62";
                requestModel.CmdList = cmdList;
                requestModel.SendCmdTimeSpan = 50;
                requestModel.ReceiveCmdTimeSpan = 1500;
                requestModel.MaxSendCount = 1;
                requestModel.AutoParse = true;
                requestModel.IsVerifyDid = true;
                requestModel.RequestMode = CanRequestMode.发送并接收;

                var 发送响应 = 数据.发送指令(requestModel);
                if (发送响应.Success == false)
                {
                    信息 = 发送响应.ErrorMessage;
                    响应值 = string.Join(",", 发送响应.ResultList ?? new List<string>());
                    return false;
                }

                信息 = string.Join(",", 发送响应.ResultList);
                响应值 = 发送响应.ResultHex;
                经纬度 = $"纬度：{发送响应.ResultHex.Substring(0, 8)}，经度：{发送响应.ResultHex.Substring(8, 8)}";

                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                响应值 = "";
                LogHelper.Error($"[Part4.读GNSS基本信息]异常，{ex.Message}，{ex.StackTrace}");
            }
            return false;
#endif
        }

        [ExposedMethodAttribute("")]
        public bool 读GNSS扩展信息(int 通道, out string 响应值, out string 信息)
        {
#if ELO20240927
            信息 = "";
            响应值 = "";
            try
            {
                List<CanCmdModel> cmdList = new List<CanCmdModel>();
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "03 22 B0 05 00 00 00 00" });
                CanReadRequestModel requestModel = new CanReadRequestModel();
                requestModel.Channel = (ushort)通道;
                requestModel.IsClearCache = false;
                requestModel.IsDecode = false;
                requestModel.DecodeLevel = "62";
                requestModel.CmdList = cmdList;
                requestModel.SendCmdTimeSpan = 50;
                requestModel.ReceiveCmdTimeSpan = 1500;
                requestModel.MaxSendCount = 1;
                requestModel.AutoParse = true;
                requestModel.IsVerifyDid = true;
                requestModel.RequestMode = CanRequestMode.发送并接收;

                var 发送响应 = 数据.发送指令(requestModel);
                if (发送响应.Success == false)
                {
                    信息 = 发送响应.ErrorMessage;
                    响应值 = string.Join(",", 发送响应.ResultList ?? new List<string>());
                    return false;
                }

                信息 = string.Join(",", 发送响应.ResultList);
                响应值 = 发送响应.ResultHex;

                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                响应值 = "";
                //LogHelper.Error($"[Part4.读GNSS扩展信息]异常，{ex.Message}，{ex.StackTrace}");
                eLog.AddLog($"[Part4.读GNSS扩展信息]异常，{ex.Message}，{ex.StackTrace}", eMsgType.Error);
            }
            return false;
#else
            信息 = "";
            响应值 = "";
            try
            {
                List<CanCmdModel> cmdList = new List<CanCmdModel>();
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "03 22 B0 05 00 00 00 00" });
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "30 08 14 00 00 00 00 00" });
                cmdList.Add(new CanCmdModel() { Id = 0x761, cmd = "30 08 14 00 00 00 00 00" });
                CanReadRequestModel requestModel = new CanReadRequestModel();
                requestModel.Channel = (ushort)通道;
                requestModel.IsClearCache = false;
                requestModel.IsDecode = false;
                requestModel.DecodeLevel = "62";
                requestModel.CmdList = cmdList;
                requestModel.SendCmdTimeSpan = 50;
                requestModel.ReceiveCmdTimeSpan = 1500;
                requestModel.MaxSendCount = 1;
                requestModel.AutoParse = true;
                requestModel.IsVerifyDid = true;
                requestModel.RequestMode = CanRequestMode.发送并接收;

                var 发送响应 = 数据.发送指令(requestModel);
                if (发送响应.Success == false)
                {
                    信息 = 发送响应.ErrorMessage;
                    响应值 = string.Join(",", 发送响应.ResultList ?? new List<string>());
                    return false;
                }

                信息 = string.Join(",", 发送响应.ResultList);
                响应值 = 发送响应.ResultHex;

                return true;
            }
            catch (Exception ex)
            {
                信息 = ex.Message;
                响应值 = "";
                LogHelper.Error($"[Part4.读GNSS扩展信息]异常，{ex.Message}，{ex.StackTrace}");
            }
            return false;
#endif
        }
    }
}
